#include "WithItem.h"
#include "IVisitor.h"

WithItem::WithItem(const exprTypePtr& context_expr, const exprTypePtr& optional_vars, int nodeId):
    WithItemType(nodeId),
    _context_expr(context_expr),
    _optional_vars(optional_vars)
{
}
    
WithItem::~WithItem()
{
    
}
    
QString WithItem::type() const
{
    return "WithItem";
}
    

exprTypePtr WithItem::context_expr()
{
    return _context_expr;
}

void WithItem::setContext_expr(const exprTypePtr& context_expr)
{
    _context_expr = context_expr;
}

exprTypePtr WithItem::optional_vars()
{
    return _optional_vars;
}

void WithItem::setOptional_vars(const exprTypePtr& optional_vars)
{
    _optional_vars = optional_vars;
}

    
QString WithItem::toString() const
{
    return QString("WithItem[context_expr=%1, optional_vars=%2]").
                arg(_context_expr ? _context_expr->toString():"").
                arg(_optional_vars ? _optional_vars->toString():"");
}
    
void WithItem::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitWithItem(node.dynamicCast<WithItem>());
}
    
void WithItem::traverse(IVisitor* visitor)
{
    if (_context_expr != NULL)
        _context_expr->accept(visitor, _context_expr);
    if (_optional_vars != NULL)
        _optional_vars->accept(visitor, _optional_vars);
}